package com.ygou.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.ygou.utils.FileUDUtil;
@Controller
public class IndexController {
	
	@RequestMapping("/upload")
	public void upload(HttpServletRequest request,HttpServletResponse response) throws IOException{
		PrintWriter out=response.getWriter();
		response.setContentType("text/html;charset=utf-8");
        int result = FileUDUtil.upload(request);  
        if(result==-2){
        	out.println("<script>" +
					"alert('暂不支持该类型文件！1');" +
					"</script>");
        }else if(result==-1){
        	out.print("<script>" +
					"alert('上传失败！2');" +
					"</script>");
        }else{
        	String str=FileUDUtil.FILENAME.toString();
        	out.print("<script>" +
					"alert('上传成功！3');" +
					"</script>");
        	
        }
	}
}
